L.Control.Export = L.Control.extend({
    statics: {
        TITLE: 'Export map',
        TITLEIMPORT: "Import",
        LABEL: '&#8965;'
    },
    options: {
        position: 'topright',
        fitBounds: true,
        layerOptions: {},
        addToMap: true,
        fileSizeLimit: 1024,
        callbackExport: function () {
        },
        callbackImport: function () {

        },
    },

    initialize: function (options) {
        L.Util.setOptions(this, options);

    },

    onAdd: function (map) {
        // Initialize map control
        return this._initContainer();
    },

    _initContainer: function () {

        var _this = this;
        // Create a button, and bind click on hidden file input
        var zoomName = 'leaflet-control-export leaflet-control-zoom',
            barName = 'leaflet-bar',
            partName = barName + '-part',
            container = L.DomUtil.create('div', zoomName + ' ' + barName);

        var link = L.DomUtil.create('a', zoomName + '-in ' + partName, container);
        link.href = '#';
        link.title = L.Control.Export.TITLE;
        var i = L.DomUtil.create('i', 'fa fa-download', link);

        L.DomEvent.disableClickPropagation(link);
        L.DomEvent.on(link, 'click', function (e) {
            _this.options.callbackExport();
            e.preventDefault();
        });


        var link2 = L.DomUtil.create('a', zoomName + '-in ' + partName, container);
        link2.href = '#';
        link2.title = L.Control.Export.TITLEIMPORT;

        var i2 = L.DomUtil.create('i', 'fa fa-upload', link2);


        L.DomEvent.disableClickPropagation(link2);
        L.DomEvent.on(link2, 'click', function (e) {
            _this.options.callbackImport();
            e.preventDefault();
        });


        return container;
    }
});

L.control.export = function (options) {
    return new L.Control.Export(options);
};